﻿<Window x:Class="WPFCABShell.$safeprojectname$.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:cab="http://schemas.scsfcontrib.com/extensions/wpf/wpfcab"
	xmlns:con="http://schemas.kent.boogaart.com/converters"
	xmlns:sys="clr-namespace:System;assembly=mscorlib"
    Title="WPF CAB $safeprojectname$"
	WindowState="Maximized">
	<Window.Resources>
		<!-- context menu shown when you right-click the tool bar tray -->
		<ContextMenu x:Key="ToolBarsContextMenu"/>

		<!-- convert from a StatusEventArgs to a Visibility depending on whether the event args are empty -->
		<con:MapConverter x:Key="StatusBarItemVisibilityConverter">
			<con:Mapping To="{x:Static Visibility.Collapsed}">
				<con:Mapping.From>
					<sys:Boolean>True</sys:Boolean>
				</con:Mapping.From>
			</con:Mapping>
			<con:Mapping To="{x:Static Visibility.Visible}">
				<con:Mapping.From>
					<sys:Boolean>False</sys:Boolean>
				</con:Mapping.From>
			</con:Mapping>
		</con:MapConverter>
	</Window.Resources>
	<Grid>
		<Grid.RowDefinitions>
			<RowDefinition Height="Auto"/>
			<RowDefinition Height="Auto"/>
			<RowDefinition Height="*"/>
			<RowDefinition Height="Auto"/>
		</Grid.RowDefinitions>
		<Grid.ColumnDefinitions>
			<ColumnDefinition Width="*"/>
			<ColumnDefinition Width="Auto"/>
		</Grid.ColumnDefinitions>

		<Menu x:Name="_menu" Grid.ColumnSpan="2"/>
		
		<ToolBarTray x:Name="_toolBarTray" Grid.Row="1" ContextMenu="{StaticResource ToolBarsContextMenu}"/>
		
		<Grid x:Name="_serverStatus" Grid.Column="1" Grid.RowSpan="2" Width="20"/>
		
		<!-- TODO: put in dock workspace -->
		<cab:TabWorkspace x:Name="_mainWorkspace" Grid.Row="2" Grid.ColumnSpan="2"/>

		<StatusBar Grid.Row="3" Grid.ColumnSpan="2">
			<StatusBar.ItemsPanel>
				<ItemsPanelTemplate>
					<Grid>
						<Grid.RowDefinitions>
							<RowDefinition Height="*"/>
						</Grid.RowDefinitions>
						<Grid.ColumnDefinitions>
							<ColumnDefinition Width="*"/>
							<ColumnDefinition Width="Auto"/>
							<ColumnDefinition Width="Auto"/>
							<ColumnDefinition Width="Auto"/>
						</Grid.ColumnDefinitions>
					</Grid>
				</ItemsPanelTemplate>
			</StatusBar.ItemsPanel>
			
			<StatusBarItem x:Name="_primaryMessageStatusBarItem" Grid.Column="0" Visibility="{Binding IsEmpty, Converter={StaticResource StatusBarItemVisibilityConverter}}">
				<TextBlock Text="{Binding Text}"/>
			</StatusBarItem>
			<StatusBarItem x:Name="_progressBarStatusBarItem" Grid.Column="1" Visibility="{Binding IsEmpty, Converter={StaticResource StatusBarItemVisibilityConverter}}">
				<StackPanel Orientation="Horizontal">
					<TextBlock Text="{Binding Text, Mode=OneWay}"/>
					<ProgressBar IsIndeterminate="{Binding IsIndeterminate, Mode=OneWay}" Minimum="{Binding Minimum, Mode=OneWay}" Maximum="{Binding Maximum, Mode=OneWay}" Value="{Binding Value, Mode=OneWay}"/>
				</StackPanel>
			</StatusBarItem>
			<StatusBarItem x:Name="_secondaryMessageStatusBarItem" Grid.Column="2" Visibility="{Binding IsEmpty, Converter={StaticResource StatusBarItemVisibilityConverter}}">
				<StackPanel Orientation="Horizontal">
					<Image Source="{Binding Image}"/>
					<TextBlock Text="{Binding Text}"/>
				</StackPanel>
			</StatusBarItem>
			<StatusBarItem x:Name="_ternaryMessageStatusBarItem" Grid.Column="3" Visibility="{Binding IsEmpty, Converter={StaticResource StatusBarItemVisibilityConverter}}">
				<StackPanel Orientation="Horizontal">
					<Image Source="{Binding Image}"/>
					<TextBlock Text="{Binding Text}"/>
				</StackPanel>
			</StatusBarItem>
		</StatusBar>
	</Grid>
</Window>
